package com.abcode.ybbemail.client.service;

import com.abcode.ybbemail.common.utils.MailUtil;
import com.abcode.ybbemail.common.vo.ResultVO;
import com.abcode.ybbemail.entity.ELogBean;
import com.abcode.ybbemail.repository.ELogRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.transaction.Transactional;

/**
 * @Description:
 * @Author:Andy.Yang
 * @Date:2019/4/25 0025
 */
@Service
@Transactional
public class EmailOperationService {

  @Autowired
  private ELogRepository eLogRepository;

  @Autowired
  private MailUtil mailUtil;

  public ResultVO emailOperationService(String to, String subject, String content) {
    mailUtil.sendSimpleMail(to,subject,content);

    ELogBean eLogBean=new ELogBean();
    eLogBean.setFdestination(to);
    eLogBean.setFsubject(subject);
    eLogBean.setFcontent(content);
    eLogRepository.save(eLogBean);
    return new ResultVO("操作成功");
  }
}
